<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<include file="Public:meta" />
</head>
<body id="main_page">
<include file="Public:position" />
<div class="container">
    <form enctype="multipart/form-data" method="post" id="frm">
      <div class="table">                  
        <div class="toolbars">
            <li class="toolbar"><a id="btnSaveAll" href="{$Url}Add"  title="添加会员分组" target="_self">添加会员分组</a></li>
            <li class="toolbar"><a id="selectall" onclick="CheckAll()"  title="全选">全选</a></li>
            <li class="toolbar"><a id="del" onclick="BatchDel()" title="批量删除">删除</a></li>
        </div>                   
        <table class="datatable" id="datatable">
            <tr>
                <th width="45px"  nowrap="nowrap">选中</th>
                <th width="90px" >会员分组ID</th>
                <th width="180px" >会员分组名称</th>
                <th width="70px" >会员数</th>
                <th width="65px" >折扣率</th>
                <th>会员分组备注</th> 
                <th width="90px" >属性</th>
                <th width="150px">操作</th>
            </tr>  
            <volist name="MemberGroup" id="mg">
                <tr id="tr{$mg.MemberGroupID}">
                    <td><eq name="mg.MemberCount" value="0"><input class="checkrow" type="checkbox" name="MemberGroupID[]" value="{$mg.MemberGroupID}" /></eq></td>
                    <td>{$mg.MemberGroupID}</td>
                    <td><b>{$mg.MemberGroupName}</b></td>
                    <td style="color:blue">{$mg.MemberCount}</td>
                    <td style="color:#FF0000">{$mg.DiscountRate}</td>
                    <td style="text-align:left;">{$mg.MemberGroupRemark}</td>
                    <td>
                    	<eq name="mg.IsSystem" value="1"><span style="color:#90F">系统</span>
                    	<else/><span style="color:green">自定义</span></eq>
                    </td> 
                    <td class="operator">
                    <a style="float:left" href="{$Url}Modify/MemberGroupID/{$mg.MemberGroupID}" id="btnEdit">修改</a>
                        <eq name="mg.IsSystem" value="0">
                            <eq name="mg.MemberCount" value="0">
                            <div class="btn-sep"></div>
                            <a style="float:left" onclick="Del({$mg.MemberGroupID})" class="btnDel">删除</a>
                            </eq>
                        </eq>
                    </td>
                </tr>
            </volist>                                
        </table>
        <div class="tfoot">
            <div id="notice">
            	<b>说明：</b><span class="notice-item">不能删除属性为系统的会员组！</span>
            </div>
        </div>
    </div>
    </form>
</div>
</body>
</html>
<script type="text/javascript">
function Del(id){
	$.confirm("{$Think.lang.DeleteTip}", function () {
		url = "{$Url}del/MemberGroupID/"+id;
		$.get(url, {}, DelComplete, "json");
	}, function () {
		return true;
	});
}

//回调函数
function DelComplete(data, textStatus){
	if (data.status == 1){
		$(data.data).css("display","none");
	}else{ 
		//删除失败
		ErrorBox(data.info);
	}
}

//批量删除
function BatchDel(){
	//var arrChk = $("input[name='InfoID[]'][checked]"); //在高速浏览器长度总是返回0
	var arrChk = $("input[name='MemberGroupID[]']");
	var n = 0;
	for(var i = 0; i < arrChk.length; i++){
		if(arrChk[i].checked) n++;
	}
	
	if( n == 0 ) {
		WarnBox("{$Think.lang.CheckDeleteTip}");
		return;
	}
	
	$.confirm("{$Think.lang.DeleteTip}", function () {
		$('#frm').attr("action", "{$Url}batchDel");
		$('#frm').submit();
	}, function () {
		return true;
	});
}
</script>